package net.daum.hibernate.sample;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.classic.Session;

public class Runner {
	public void run(RunItem runItem) throws Exception {
		SessionFactory sessionFactory = new AnnotationConfiguration()
				.configure("net/daum/hibernate/sample/hibernate.cfg.xml")
				.buildSessionFactory();

		Session session = sessionFactory.openSession();
		session.beginTransaction();

		runItem.run(session);
		
		session.getTransaction().commit();
		session.close();
	}
}
